<template>
	<view style="position: relative;background-color: #f9f3c1; height: 100vh;width: 100%;">
		<image class="footer-image" mode="aspectFit" src="https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/2024/08/20/17740181-35152362-02.jpg"
			@error="imageError"></image>
<!-- 		<view style="position: absolute;width: 100%;top: -112rpx;">
			<image style="width: 100%;" mode="aspectFit" src="https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/2024/08/20/17740181-35152362-02.jpg"
				@error="imageError"></image>
		</view> -->
		<view class="" style="position: absolute;width: 100%;top: 260rpx;z-index: 2;
			display: flex;
		    align-items: center;
		    flex-direction: column;
		    flex-wrap: nowrap;
		">
			<img @click="xgncytx()" class="cu-avatar xl round margin-left txbjc" :src="vk.getVuex('$user.userInfo.avatar') || defaultAvatarUrll">
			<text style="top: 80rpx;position: absolute;font-weight: bold;font-size: initial;">{{userdata.nickname}}</text>
		</view>
		<view class="" style="position: absolute;background-color: #f9f3c1;min-height:1030rpx;width: 100%;top: 257rpx;
		padding: 10px;text-align: center;">
			<image v-if="gsxyxmtkhxsuser && gsxyxmtkhxsuser.gzzimg" style="width:600rpx;
			margin-top: 70px;
			border-radius: 10px;" mode="widthFix" :src="gsxyxmtkhxsuser.gzzimg"></image>
		</view>
<!-- 		<view v-if="gsxyxmtkhxsuser && gsxyxmtkhxsuser.gzzimg" style="padding: 10px;position: absolute;">
			<image style="width:100%;" mode="widthFix" :src="gsxyxmtkhxsuser.gzzimg"></image>
		</view> -->
	</view>
</template>
<script>
	var vk = uni.vk;
	var that;
	export default {
		components: {},
		data() {
			// 页面数据变量
			return {
				gsxyxmtkhxsuser:{
					gzzimg:"",
					title:"工作证"
				},
				defaultAvatarUrll: 'https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/cloudstorage/14356c11-7c59-436b-a12c-9dd1f2a7704d.jpg',
				options: {},
				watchStr: '',
				userInfo: {},
				hasWeixinAuth: true,
				encryptedKey: "",
				image: "",
				gridBorder: false,
				gridCol: 3,
				modalName: null,
				xywxsf:null,
				// init请求返回的数据
				userdata: {},
				data: {

				},
				scrollTop: 0
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		async onLoad(options = {}) {
			vk = uni.vk;
			that = this;
			await this.tzgga()
			that.userdata = vk.getVuex("$user.userInfo")
		},
		async onReady() {},
		async onShow() {
			
			
			// //console.log(that.userdata)
			// if (that.userdata) {
			// 	uni.setNavigationBarTitle({
			// 		title: that.userdata.nickname
			// 	});
			// }
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {

		},
		// 监听 - 点击右上角转发时
		onShareAppMessage(options) {

		},
		// 函数
		methods: {
			imageError(e){
				console.log(e)
			},
			getxybxsf(){
				return vk.callFunction({
					url: 'client/gsxy/xybx/pub/xybxapi.getGsxyxybxsjobjList',
					data: {}
				}).then((data) => {
					this.xywxsf = data.list
					console.log(this.xywxsf)
				}).catch((err) => {});
			},
			tzgga() {
				return vk.callFunction({
					url: 'client/gsxy/xmtdk/pub/xmtdk-xs-api.getgzjimg',
					data: {
						userid: vk.getVuex("$user.userInfo._id")
					}
				}).then((data) => {
					this.gsxyxmtkhxsuser = data.info
					this.gsxyxmtkhxsuser.title = '工作证'
				}).catch((err) => {});
			},
			xgncytx() {
				if(that.userdata.nickname && that.userdata.avatar){}else{vk.navigateTo('/pages_bd/dlyemian/set-user-info')}
			},
			// 微信登陆
			loginByWeixin(type) {
				let objuser = uni.getStorageSync('wxuser_key');
				let nowsj = Date.now();
				if (objuser && objuser > nowsj) {
					vk.navigateTo('/pages_bd/dlyemian/set-user-info');
				} else {
					vk.userCenter.loginByWeixin({
						data: {
							type
						},
						success: (data) => {
							that.userInfo.token1 = data.tokenExpired
							try {
								uni.setStorageSync('wxuser_key', that.userInfo.token1);
							} catch (e) {
								// error
							}
						}
					});
				}
			},
			Gridchange(e) {
				this.gridCol = e.detail.value
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
		},
		// 监听器
		watch: {
			"$store.state.$user.userlnfo": {
				deep: true, // 如果是对象，需要深度监听设置为 true
				handler: function(newVal, oldVal) {
					this.watchStr = `数据发生变化啦，值从 ${oldVal} 变为 ${newVal}`;
					//console.log(this.watchStr);
				}
			}
		},
		// 计算属性
		computed: {

		}
	}
</script>
<style lang="scss" scoped>
	.footer-image {
			position: fixed;
			top: -125rpx;
			width: 100%;
	}
	.txbj {
		position: relative;
		// width: 100%;
		height: 300rpx;
		background-image: url("https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/2024/08/20/17740181-35152362-02.jpg");
		background-position: center;
		background-size: cover;
		background-repeat: no-repeat;
	}
	.txbjc {
		position: absolute;
		left: 45%;
		top: 65%;
		transform: translate(-50%, -50%);
	}
</style>